package com.zuxia.service.impl;

import java.util.List;

import javax.annotation.Resource;
import org.springframework.stereotype.Service;
import com.zuxia.dao.impl.AdminDao;
import com.zuxia.entity.Admin;
import com.zuxia.service.IAdminService;

@Service("adminService")
public class AdminService implements IAdminService {
	@Resource(name="adminDao")
	private AdminDao adminDao;
	
	public List<Admin> login(String name,String pwd) {
		return adminDao.login(name,pwd);
	}

	public List<Admin> selectAll() {
		return adminDao.selectAll();
	}
	
	public Admin selectId(int id) {
		return adminDao.selectId(id);
	}

	public boolean deleteAdmin(Admin admin) {
		int i = adminDao.deleteAdmin(admin);
		if(i>0) {
			return true;
		}
		return false;
	}
	
	public boolean saveAdmin(Admin admin) {
		int i = adminDao.saveAdmin(admin);
		if(i>0) {
			return true;
		}
		return false;
	}

	public String updateAdmin(Admin admin) {
		try {
			adminDao.updateAdmin(admin);
			return "updateAdmin";
		} catch (Exception e) {
			System.out.println("修改失败！！");
			return "error";
		}
	}
}
